home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_qt.idb / usr / freeware / include / Qt / qtableview.h.z / qtableview.h
Encoding:
C/C++ Source or Header  |  1998-10-28  |  6.6 KB  |  256 lines

  1. /**********************************************************************
  2. ** $Id: qtableview.h,v 2.11 1998/07/03 00:09:54 hanord Exp $
  3. **
  4. ** Definition of QTableView class
  5. **
  6. ** Created : 941115
  7. **
  8. ** Copyright (C) 1992-1998 Troll Tech AS.  All rights reserved.
  9. **
  10. ** This file is part of Qt Free Edition, version 1.40.
  11. **
  12. ** See the file LICENSE included in the distribution for the usage
  13. ** and distribution terms, or http://www.troll.no/free-license.html.
  14. **
  15. ** IMPORTANT NOTE: You may NOT copy this file or any part of it into
  16. ** your own programs or libraries.
  17. **
  18. ** Please see http://www.troll.no/pricing.html for information about 
  19. ** Qt Professional Edition, which is this same library but with a
  20. ** license which allows creation of commercial/proprietary software.
  21. **
  22. *****************************************************************************/
  23.  
  24. #ifndef QTABLEVIEW_H
  25. #define QTABLEVIEW_H
  26.  
  27. #ifndef QT_H
  28. #include "qframe.h"
  29. #endif // QT_H
  30.  
  31. class QScrollBar;
  32. class CornerSquare;
  33.  
  34.  
  35. class QTableView : public QFrame
  36. {
  37.     Q_OBJECT
  38. public:
  39.     void    setBackgroundColor( const QColor & );
  40.     void    setPalette( const QPalette & );
  41.     void    show();
  42.  
  43.     void    repaint( bool erase=TRUE );
  44.     void    repaint( int x, int y, int w, int h, bool erase=TRUE );
  45.     void    repaint( const QRect &, bool erase=TRUE );
  46.  
  47. protected:
  48.     QTableView( QWidget *parent=0, const char *name=0, WFlags f=0 );
  49.    ~QTableView();
  50.  
  51.     int        numRows()    const;
  52.     void    setNumRows( int );
  53.     int        numCols()    const;
  54.     void    setNumCols( int );
  55.  
  56.     int        topCell()    const;
  57.     void    setTopCell( int row );
  58.     int        leftCell()    const;
  59.     void    setLeftCell( int col );
  60.     void    setTopLeftCell( int row, int col );
  61.  
  62.     int        xOffset()    const;
  63.     void    setXOffset( int );
  64.     int        yOffset()    const;
  65.     void    setYOffset( int );
  66.     void    setOffset( int x, int y, bool updateScrBars = TRUE );
  67.  
  68.     virtual int cellWidth( int col );
  69.     virtual int cellHeight( int row );
  70.     int        cellWidth()    const;
  71.     int        cellHeight()    const;
  72.     void    setCellWidth( int );
  73.     void    setCellHeight( int );
  74.  
  75.     virtual int totalWidth();
  76.     virtual int totalHeight();
  77.  
  78.     uint    tableFlags()    const;
  79.     bool    testTableFlags( uint f ) const;
  80.     void    setTableFlags( uint f );
  81.     void    clearTableFlags( uint f = ~0 );
  82.  
  83.     bool    autoUpdate()     const;
  84.     void    setAutoUpdate( bool );
  85.  
  86.     void    updateCell( int row, int column, bool erase=TRUE );
  87.  
  88.     QRect    cellUpdateRect() const;
  89.     QRect    viewRect()     const;
  90.  
  91.     int        lastRowVisible() const;
  92.     int        lastColVisible() const;
  93.  
  94.     bool    rowIsVisible( int row ) const;
  95.     bool    colIsVisible( int col ) const;
  96.  
  97.     const QScrollBar *verticalScrollBar() const;
  98.     const QScrollBar *horizontalScrollBar() const;
  99.  
  100. private slots:
  101.     void    horSbValue( int );
  102.     void    horSbSliding( int );
  103.     void    horSbSlidingDone();
  104.     void    verSbValue( int );
  105.     void    verSbSliding( int );
  106.     void    verSbSlidingDone();
  107.  
  108. protected:
  109.     virtual void paintCell( QPainter *, int row, int col ) = 0;
  110.     virtual void setupPainter( QPainter * );
  111.  
  112.     void    paintEvent( QPaintEvent * );
  113.     void    resizeEvent( QResizeEvent * );
  114.  
  115.     int        findRow( int yPos ) const;
  116.     int        findCol( int xPos ) const;
  117.  
  118.     bool    rowYPos( int row, int *yPos ) const;
  119.     bool    colXPos( int col, int *xPos ) const;
  120.  
  121.     int        maxXOffset();
  122.     int        maxYOffset();
  123.     int        maxColOffset();
  124.     int        maxRowOffset();
  125.  
  126.     int        minViewX()    const;
  127.     int        minViewY()    const;
  128.     int        maxViewX()    const;
  129.     int        maxViewY()    const;
  130.     int        viewWidth()    const;
  131.     int        viewHeight()    const;
  132.  
  133.     void    scroll( int xPixels, int yPixels );
  134.     void    updateScrollBars();
  135.     void    updateTableSize();
  136.  
  137. private:
  138.     void    coverCornerSquare( bool );
  139.     void    snapToGrid( bool horizontal, bool vertical );
  140.     void    setHorScrollBar( bool on, bool update = TRUE );
  141.     void    setVerScrollBar( bool on, bool update = TRUE );
  142.     void    updateView();
  143.     int        findRawRow( int yPos, int *cellMaxY, int *cellMinY = 0,
  144.                 bool goOutsideView = FALSE ) const;
  145.     int        findRawCol( int xPos, int *cellMaxX, int *cellMinX = 0,
  146.                 bool goOutsideView = FALSE ) const;
  147.     int        maxColsVisible() const;
  148.  
  149.     void    updateScrollBars( uint );
  150.     void    updateFrameSize();
  151.  
  152.     void    doAutoScrollBars();
  153.     void    showOrHideScrollBars();
  154.  
  155.     int        nRows;
  156.     int        nCols;
  157.     int        xOffs, yOffs;
  158.     int        xCellOffs, yCellOffs;
  159.     short    xCellDelta, yCellDelta;
  160.     short    cellH, cellW;
  161.  
  162.     uint    obsoleteUpd        : 1;
  163.     uint    eraseInPaint        : 1;
  164.     uint    verSliding        : 1;
  165.     uint    verSnappingOff        : 1;
  166.     uint    horSliding        : 1;
  167.     uint    horSnappingOff        : 1;
  168.     uint    coveringCornerSquare    : 1;
  169.     uint    sbDirty            : 8;
  170.     uint    inSbUpdate        : 1;
  171.  
  172.     uint    tFlags;
  173.     QRect    cellUpdateR;
  174.  
  175.     QScrollBar *vScrollBar;
  176.     QScrollBar *hScrollBar;
  177.     CornerSquare *cornerSquare;
  178.  
  179. private:    // Disabled copy constructor and operator=
  180.     QTableView( const QTableView & );
  181.     QTableView &operator=( const QTableView & );
  182. };
  183.  
  184.  
  185. const uint Tbl_vScrollBar    = 0x00000001;
  186. const uint Tbl_hScrollBar    = 0x00000002;
  187. const uint Tbl_autoVScrollBar    = 0x00000004;
  188. const uint Tbl_autoHScrollBar    = 0x00000008;
  189. const uint Tbl_autoScrollBars    = 0x0000000C;
  190.  
  191. const uint Tbl_clipCellPainting = 0x00000100;
  192. const uint Tbl_cutCellsV    = 0x00000200;
  193. const uint Tbl_cutCellsH    = 0x00000400;
  194. const uint Tbl_cutCells        = 0x00000600;
  195.  
  196. const uint Tbl_scrollLastHCell    = 0x00000800;
  197. const uint Tbl_scrollLastVCell    = 0x00001000;
  198. const uint Tbl_scrollLastCell    = 0x00001800;
  199.  
  200. const uint Tbl_smoothHScrolling = 0x00002000;
  201. const uint Tbl_smoothVScrolling = 0x00004000;
  202. const uint Tbl_smoothScrolling    = 0x00006000;
  203.  
  204. const uint Tbl_snapToHGrid    = 0x00008000;
  205. const uint Tbl_snapToVGrid    = 0x00010000;
  206. const uint Tbl_snapToGrid    = 0x00018000;
  207.  
  208.  
  209. inline int QTableView::numRows() const
  210. { return nRows; }
  211.  
  212. inline int QTableView::numCols() const
  213. { return nCols; }
  214.  
  215. inline int QTableView::topCell() const
  216. { return yCellOffs; }
  217.  
  218. inline int QTableView::leftCell() const
  219. { return xCellOffs; }
  220.  
  221. inline int QTableView::xOffset() const
  222. { return xOffs; }
  223.  
  224. inline int QTableView::yOffset() const
  225. { return yOffs; }
  226.  
  227. inline int QTableView::cellHeight() const
  228. { return cellH; }
  229.  
  230. inline int QTableView::cellWidth() const
  231. { return cellW; }
  232.  
  233. inline uint QTableView::tableFlags() const
  234. { return tFlags; }
  235.  
  236. inline bool QTableView::testTableFlags( uint f ) const
  237. { return (tFlags & f) != 0; }
  238.  
  239. inline QRect QTableView::cellUpdateRect() const
  240. { return cellUpdateR; }
  241.  
  242. inline bool QTableView::autoUpdate() const
  243. { return isUpdatesEnabled(); }
  244.  
  245. inline void QTableView::repaint( bool erase )
  246. { repaint( 0, 0, width(), height(), erase ); }
  247.  
  248. inline void QTableView::repaint( const QRect &r, bool erase )
  249. { repaint( r.x(), r.y(), r.width(), r.height(), erase ); }
  250.  
  251. inline void QTableView::updateScrollBars()
  252. { updateScrollBars( 0 ); }
  253.  
  254.  
  255. #endif // QTABLEVIEW_H
  256.